package net.ib.mtalk.ui.attachment.geotag;

import java.util.ArrayList;

import android.graphics.drawable.Drawable;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;

public class GeoOverlay extends ItemizedOverlay{
	private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
	private GeotagActivity mContext;
	
	public GeoOverlay(Drawable defaultMarker, GeotagActivity context) {
		super(boundCenter(defaultMarker));
		// TODO Auto-generated constructor stub
		mContext = context;
	}
	
	public void addOverlay(OverlayItem overlay){
		mOverlays.add(overlay);
		populate();
	}
	
	public void deleteOverlay(OverlayItem overlay){
		mOverlays.clear();
		populate();
	}
	
	@Override
	protected OverlayItem createItem(int arg0) {
		return mOverlays.get(arg0);
	}

	@Override
	public int size() {
		return mOverlays.size();
	}
	
	@Override
	public boolean onTap(GeoPoint arg0, MapView arg1 ){
		System.out.println(arg0);
		mContext.selectPoint(arg0);
		return false;
	}
}
